<script setup lang="ts">
import {defineProps, PropType} from 'vue'
import BlogTag from "@/components/BlogTag.vue";
defineProps({
  site: {
    type: Object as PropType<FriendLinkVO>,
    default: () => {
      return {
        id: 1,
        siteName: '',
        siteUrl: '',
        remark: '',
        logoUrl: '',
        extraVoList: []
      } as FriendLinkVO
    }
  }
})
</script>

<template>
  <div class="link-card">
    <div class="site-container">
      <div class="site-logo">
        <img v-lazy="site.logoUrl" alt="" />
      </div>
      <div class="site-info">
        <a class="site-name" :href="site.siteUrl">{{ site.siteName }}</a>
        <div class="site-description">
          {{ site.remark }}
        </div>
      </div>
    </div>
    <div class="article-list">
      <div class="article-item" v-for="article in site.extraVoList" :key="article.id">
        <img class="article-cover" v-lazy="article.articleCover" alt="" />
        <div class="article-title">
          <a :href="article.articleUrl">{{ article.title }}</a>
          <BlogTag transparent font-size="12px" icon="article" text="文章" color="#fff"/>
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped lang="less">
.link-card {
  width: 305px;
  height: 208px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid #e0e0e0;
  padding: 24px;
  box-sizing: border-box;
}
.site-container {
  display: flex;
  align-items: center; // 垂直居中
  gap: 12px;
  .site-logo {
    min-width: 54px;
    width: 54px;
    height: 54px;
    border: 1px solid #e0e0e0;
    //box-sizing: border-box;
    border-radius: 50%;
    overflow: hidden;
    & > img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }
  }
  .site-info {
    flex: 1;
    overflow: hidden;         /* 超出容器部分隐藏 */
    .site-name {
      color: #333333;
      font-weight: 500;
      font-size: 20px;
      line-height: 29px;
      text-decoration: none; // 去掉链接下划线
      &:hover {
        color: #EB5C88;
      }
    }
    .site-description {
      margin-top: 4px;
      color: #666666;
      font-weight: 400;
      font-size: 14px;
      line-height: 20px;
    }
  }
}
.site-name, .site-description {
  white-space: nowrap;      /* 确保文本不换行 */
  overflow: hidden;         /* 超出容器部分隐藏 */
  text-overflow: ellipsis;  /* 超出部分显示省略号 */
}
.article-list {
  margin-top: 26px;
  display: flex;
  align-items: center;
  gap: 8.5px;
  .article-item {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    & > img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      object-position: 0 25%; // 将图片顶部对齐
    }
    & > .article-title {
      position: absolute;
      top: 0;
      left: 0;
      margin: 12px;
      opacity: 0;
      &  > a {
        color: #ffffff;
        font-weight: 500;
        font-size: 14px;
        line-height: 20px;
        text-decoration: none; // 去掉链接下划线
        width: 96px;
        height: 60px;
        overflow: hidden;         /* 超出容器部分隐藏 */
        text-overflow: ellipsis;  /* 超出部分显示省略号 */
      }
    }
    &:hover {
      transform: scale(1.5);
      //transition: transform 0.3s ease-in-out;
      transition: transform 0.3s ease; /* 平滑放大动画 */
      // 悬浮时显示背景
      &::before {
        opacity: 1;
      }
      & > .article-title {
        opacity: 1;
      }
    }
    &::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: rgba(0, 0, 0, 4%); /* 半透明黑色背景 */
      backdrop-filter: blur(32px);
      opacity: 0; /* 默认隐藏 */
      transition: opacity 0.3s ease; /* 透明度过渡 */
    }
  }
}
</style>
